<?php       
    function db_connect()
    {
        $server = 'localhost';
        $username = 'root';
        $password = '';
        $db = 'teknog';
        
        $connection = new mysqli($server, $username, $password, $db);
        
        if (mysqli_connect_error())
        {
            die("Database connection failed: " . mysqli_connect_error());
        }
        
        return $connection;
    }
    
    function insert($connection, $query)
    {
        if(!$connection->query($query))
        {
            die("Can't insert to database.");
        }
    }
    
    function insert_multiple($connection, $query)
    {
        if(!$connection->multi_query($query))
        {
            die("Can't insert to database.");
        }
    }
    
    function select($connection, $query)
    {
        return $connection->query($query);
    }
    
    function update($connection, $query)
    {
        if ($connection->query($sql) === TRUE) 
        {
            return 0;
        }
        else 
        {
            return 1;
        }
    }
    
    function delete($connection, $query)
    {
        if ($connection->query($sql) === TRUE) 
        {
            return 0;
        }
        else 
        {
            return 1;
        }
    }